import type { QueryParams, PostDetailResponse, PostParams, PostItem } from './type'
import { http } from '@/utils/request'

const prefix = import.meta.env.VITE_API_SYS

// 查询岗位列表
export function listPost(query: QueryParams) {
	return http.get<ResPage<PostItem[]>>(`${prefix}/post/list`, query)
}

// 查询岗位详细
export function getPost(postId: string) {
	return http.get<PostItem>(`${prefix}/post/${postId}`)
}

// 新增岗位
export function addPost(data: PostParams) {
	return http.post(`${prefix}/post`, data)
}

// 修改岗位
export function updatePost(data: PostParams) {
	return http.put(`${prefix}/post`, data)
}

// 删除岗位
export function delPost(postId: string) {
	return http.delete(`${prefix}/post/${postId}`)
}

// 导出
export function postExport(data: QueryParams) {
	return http.postFile<ExportResponse>(`${prefix}/post/export`, data, {
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		responseType: 'blob'
	})
}
